package com.usian.user.controller.v1;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.usian.common.dtos.PageResult;
import com.usian.common.dtos.ResponseResult;
import com.usian.common.enums.AppHttpCodeEnum;
import com.usian.model.user.dtos.AuthDto;
import com.usian.model.user.dtos.UserAuthDto;
import com.usian.user.entity.ApUserAuth;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.usian.user.service.IApUserAuthService;
import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * APP实名认证信息表 前端控制器
 * </p>
 *
 * @author usian
 * @since 2022-07-05
 */
@RestController
@RequestMapping("/api/v1/auth")
@Api(tags = "APP实名认证信息表接口")
@CrossOrigin
public class ApUserAuthController{

    @Autowired
    private IApUserAuthService apUserAuthService;

    /**
     * 按照状态查询用户认证列表及分页
     * @param authDto
     * @return
     */
    @PostMapping("/list")
    public PageResult<UserAuthDto> findByPage(@RequestBody AuthDto authDto){
        return apUserAuthService.findByPage(authDto);
    }
    /**
     * 审核通过
     */
    @PostMapping("/authPass")
    public ResponseResult authPass(@RequestBody AuthDto authDto){
        apUserAuthService.updateAuthStatus(authDto, ApUserAuth.Status.PASS.getCode());
        return  ResponseResult.ok();
    }
    /**
     * 审核未通过
     */
    @PostMapping("/authFail")
    public ResponseResult authFail(@RequestBody AuthDto authDto){
        apUserAuthService.updateAuthStatus(authDto, ApUserAuth.Status.FAIL.getCode());
        return  ResponseResult.ok();
    }

}
